package com.ajz.manager.api;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ajz.common.constants.SwaggerApiConstant;
import com.ajz.common.dto.Result;
import com.ajz.config.AppUserUtil;
import com.ajz.manager.service.CollectService;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * <p> 收藏</p>
 *
 * @author xyj
 * @date 2018年11月14日
 */
@RestController
@RequestMapping("/api/collect")
public class CollectController {
	@Inject
	private CollectService collectService;
	/**
	 * 加入收藏
	 * @param request
	 * @return
	 */
	@ApiOperation(value = SwaggerApiConstant.COLLECT_ADD)
	@GetMapping(value = "/add")
	@ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "TOKEN", paramType = "header") })
	public Result collectAdd(HttpServletRequest request) {
		return Result.successResult(AppUserUtil.getUser(request));
	}
	/**
	 * 取消收藏
	 * @param request
	 * @return
	 */
	@ApiOperation(value = SwaggerApiConstant.COLLECT_DEL)
	@GetMapping(value = "/del")
	@ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "TOKEN", paramType = "header") })
	public Result collectDel(HttpServletRequest request) {
		return Result.successResult(AppUserUtil.getUser(request));
	}
	/**
	 * 收藏列表
	 * @param request
	 * @return
	 */
	@ApiOperation(value = SwaggerApiConstant.COLLECT_LIST)
	@GetMapping(value = "/list")
	@ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "TOKEN", paramType = "header") })
	public Result collectList(HttpServletRequest request,@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
			@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
		Pageable pageable = new PageRequest(pageNum,pageSize);
		
		return Result.successResult(AppUserUtil.getUser(request));
	}
}
